import { upperFirst } from '../../.internal/lodash/upperFirst.js';
import { words } from '../../.internal/lodash/words.js';
import { toString } from '../../.internal/lodash/toString.js';

/**
 * @desc    转换字符串string为驼峰写法。
 * @param   {[string='']} string 要转换的字符串
 * @return  {String} 返回驼峰写法的字符串
 */

const camelCase = (string) =>
	words(toString(string).replace(/['\u2019]/g, '')).reduce((result, word, index) => {
		word = word.toLowerCase();
		return result + (index ? upperFirst(word) : word);
	}, '');

export { camelCase };